/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dat;

import com.casestudy1.main.MainMidlet;
import com.casestudy1.view.View;
import com.sun.lwuit.Command;

/**
 * @author My PC
 */
import com.sun.lwuit.Display;
import com.sun.lwuit.*;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Border;
import com.sun.lwuit.plaf.Style;
import com.sun.lwuit.util.Resources;
import java.io.IOException;

public class Main extends View {

    Command cmBack, cmExit;

    public Main(final MainMidlet midlet) {
        super(midlet);

        Resources res = null;
        try {
            res = Resources.open("/mytheme.res");//open resource  

        } catch (IOException e) {
        }

        setTitle("Vui chơi giải trí");
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));

        setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, false, 1000));

        RadioButton rb1 = new RadioButton(" Cinema", res.getImage("Image5"));
        RadioButton rb3 = new RadioButton(" Shopping", res.getImage("Image6"));
        RadioButton rb4 = new RadioButton(" Restaurant", res.getImage("Image7"));
        RadioButton rb2 = new RadioButton(" Park", res.getImage("Image8"));

        ButtonGroup group1 = new ButtonGroup();
        group1.add(rb1);
        group1.add(rb2);
        group1.add(rb3);
        group1.add(rb4);

        rb1.getStyle().setFgColor(0x00CCFF);
        rb2.getStyle().setFgColor(0x00CCFF);
        rb3.getStyle().setFgColor(0x00CCFF);
        rb4.getStyle().setFgColor(0x00CCFF);

        Style s4 = new Style();
        s4.setBorder(Border.createEmpty());
        s4.setAlignment(CENTER);
        s4.setBgColor(0x000000);

        Button btn1 = new Button(res.getImage("Image9"));
        btn1.getStyle().setAlignment(CENTER);
        btn1.setText("Go now !");
        btn1.getStyle().setBorder(Border.createEmpty());
        btn1.getStyle().setPadding(3, 2, 1, 1);
        btn1.setPressedStyle(s4);


        btn1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                midlet.showRCPForm();
            }
        });

        cmExit = new Command("Thoát");
        cmBack = new Command("Quay lại");

        cmExit = new Command("Thoát") {
            public void actionPerformed(ActionEvent evt) {
                Display.getInstance().exitApplication();
            }
        };

        cmBack = new Command("Quay lại") {
            public void actionPerformed(ActionEvent evt) {
                midlet.showMainMenu();

            }
        };

        addComponent(rb1);
        addComponent(rb2);
        addComponent(rb3);
        addComponent(rb4);
        addComponent(btn1);

        setBackCommand(cmBack);
        addCommand(cmBack);
        addCommand(cmExit);

    }
}